#include "MyMap.h"
#include <QPluginloader>
#include <QIcon>
#include <QGLWidget>
#include <QRectF>
#include <QTimer>
#include <QThread>
#include <QDesignerCustomWidgetInterface>
#include "QGridLayout"
#include "MyScene.h"
#include "MyView.h"
#include "MapEngine.h"
#include "HttpLoader.h"
#include <QMouseEvent>
MyMap::MyMap(QWidget *parent)
	: QMainWindow(parent), m_pScene(NULL),
	m_pView(NULL), m_pDownLoader(NULL)
	, m_pMyTileSources(NULL)
{
	ui.setupUi(this);
	
	setWindowIcon(QIcon(":/new/prefix1/sda/logo.ico"));
	InitMap();
}

MyMap::~MyMap()
{
}

void MyMap::InitMap()
{
	m_pMapStatus = new MapStatus;
	m_pMapStatus->Map_Level = 4;
	m_pMapStatus->Map_Center=QPointF(0,0);


	m_pScene = new MyScene;

	m_pView = new MyView(m_pMapStatus);

	m_pView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	m_pView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	
	m_pView->setDragMode(QGraphicsView::DragMode::ScrollHandDrag);
	
	this->setCentralWidget(m_pView);
	m_pView->setScene(m_pScene);
	QTimer::singleShot(2000, this, SLOT(UpdateMap()));
	connect(this->ui.action_ShowImage, SIGNAL(triggered()),this,SLOT(ShowImage()));
	connect(this->ui.action_ShowImagewithoutNots, SIGNAL(triggered()), this, SLOT(ShowImageWithoutNotes()));
	connect(this->ui.action_ShowVetorTile, SIGNAL(triggered()), this, SLOT(ShowVectorTile()));
	connect(this->ui.action_ShowterrianTile, SIGNAL(triggered()), this, SLOT(ShowTerrian()));
	connect(this->ui.action_ShowTerrainWithoutNotes, SIGNAL(triggered()), this, SLOT(ShowTerrianWithoutNotes()));
}

void MyMap::MouseMovew()
{
	
}

void MyMap::ScaleChange()
{
	/*if (m_pEngine != NULL)
	{
		m_pEngine->ScalesChange();
	}*/
}

void MyMap::ShowImage()
{
	if (m_pView)
	{
		m_pView->ShowImage();
	}
}

void MyMap::ShowImageWithoutNotes()
{
	if (m_pView)
	{
		m_pView->ShowImageWithoutNotes();
	}
}

void MyMap::ShowVectorTile()
{
	if (m_pView)
	{
		m_pView->ShowVectorTile();
	}
}

void MyMap::ShowTerrian()
{
	if (m_pView)
	{
		m_pView->ShowTerrian();
	}
}



void MyMap::ShowTerrianWithoutNotes()
{
	if (m_pView)
	{
		m_pView->ShowTerrianWithoutNotes();
	}
}

void MyMap::UpdateMap()
{
	if (m_pView!=NULL)
	{
		m_pView->UpdateMap();
	}
	/*;*/
}
